Skip to main content

Body Event

Description:

  This is just a demonstration record showing some signal slot events that are used when the receivingContact property of a Body is set to true. And they are meant to be used for collision detection between Body objects.

Usage:

-- you can register for these events using codes
body.receivingContact = true
body:slot("BodyEnter", function(other: Body, sensorTag: integer)
print("A body enter senser", other, sensorTag)
end)

BodyEnter

Type: Node Event.

Description:

  Triggers when a Body object collides with a sensor object.

Signature:

["BodyEnter"]: function(other: Body, sensorTag: integer)

Parameters:

ParameterTypeDescription
otherBodyThe other Body object that the current Body is colliding with.
sensorTagintegerThe tag of the sensor that triggered this collision.

BodyLeave

Type: Node Event.

Description:

  Triggers when a Body object is no longer colliding with a sensor object.

Signature:

["BodyLeave"]: function(other: Body, sensorTag: integer)

Parameters:

ParameterTypeDescription
otherBodyThe other Body object that the current Body is no longer colliding with.
sensorTagintegerThe tag of the sensor that triggered this collision.

ContactStart

Type: Node Event.

Description:

  Triggers when a Body object starts to collide with another object.

Signature:

["ContactStart"]: function(other: Body, point: Vec2, normal: Vec2)

Parameters:

ParameterTypeDescription
otherBodyThe other Body object that the current Body is colliding with.
pointVec2The point of collision in world coordinates.
normalVec2The normal vector of the contact surface in world coordinates.

ContactEnd

Type: Node Event.

Description:

  Triggers when a Body object stops colliding with another object.

Signature:

["ContactEnd"]: function(other: Body, point: Vec2, normal: Vec2)

Parameters:

ParameterTypeDescription
otherBodyThe other Body object that the current Body is no longer colliding with.
pointVec2The point of collision in world coordinates.
normalVec2The normal vector of the contact surface in world coordinates.